package com.ian.controller;

import com.ian.service.PerUserService;
import com.ian.util.ResultMsg;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

@RestController
public class LoginController {
    @Autowired
    PerUserService perUserService;

    Map res=new HashMap();

    @PostMapping("/login")
    public Map login(@RequestParam("mobile") String mobile, @RequestParam("pwd") String pwd) {
        try{
            perUserService.selectByTelAndPwd(mobile, pwd);
            res.put("code", 7001);
            res.put("msg", "登录成功");
            res.put("data", mobile);
        } catch (Exception e) {
            res.put("code", 7002);
            res.put("msg", "登录失败");
        }
        return res;
    }

    @GetMapping("/detail")
    public Map detail() {
        res.put("code", 200);
        res.put("data", "笔记本");
        return res;
    }

    @GetMapping("/pay")
    public String pay() {
        System.out.println("ooooKKKKK");
        return "success";
    }
}
